package utils;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.IOException;

/**
 * @author hxc
 * @Description: 获取数据库配置文件工具
 *
 * */
public class MapperUtil {
    public static final SqlSessionFactory sqlSessionFactory_mysql=getSqlSessionFactory("mysql-config.xml");

    private static SqlSessionFactory getSqlSessionFactory(String configFile){
        SqlSessionFactory sqlSessionFactory=null;
        try{
            sqlSessionFactory =new SqlSessionFactoryBuilder().build(Resources.getResourceAsStream(configFile));
        }catch(IOException e){
            e.printStackTrace();
        }
        return sqlSessionFactory;
    }
}
